package com.alon.spring01.controller;

import com.alon.spring01.common.config.pool.AsyncTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: spring01
 * @description: 线程池任务控制器
 * @author: yulongguang
 * @create: 2019-04-12 11:44
 **/
@RestController
@RequestMapping("/task")
@Slf4j
@Api("TaskController相关的api")
public class TaskController {

    @Autowired
    private AsyncTask asyncTask;

    @ApiOperation(value = "启动任务", notes = "启动任务")
    @GetMapping("/startTask")
    public void startTask() {
        List<Integer> list=new ArrayList<>();
        for (int i=0;i<100000;i++){
            list.add(i);
        }

        for (int i = 0; i < 5; i++) {
            asyncTask.doTask(list);
        }

        log.info("所有的task启动完");
    }
}
